package com.example.strategyNew;

import com.google.common.collect.ImmutableMap;

public enum StrategyType {
    DATA_PAY("1", new DataPayServiceStrategyImpl()),
    QN("2", new QnServiceStrategyImpl()),
    CFCA("3", new CfcaServiceStrategyImpl());

    private String type;
    private ThirdServiceStrategy serviceStrategy;

    StrategyType(String type, ThirdServiceStrategy serviceStrategy) {
        this.type = type;
        this.serviceStrategy = serviceStrategy;
    }

    /**
     * id enum map
     */
    private static final ImmutableMap<String, StrategyType> INT_ENUM_MAP;

    static {
        final ImmutableMap.Builder<String, StrategyType> builder = new ImmutableMap.Builder<>();
        for (final StrategyType value : StrategyType.values()) {
            builder.put(value.type, value);
        }
        INT_ENUM_MAP = builder.build();
    }

    /**
     * string to enum
     *
     * @param value 待转换枚举值
     * @return GenerateSlipIdTypeEnum
     */
    public static StrategyType of(final String value) {
        return INT_ENUM_MAP.get(value);
    }
}
